package common

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

var Response = new(response)

type response struct{}

func (response) Success(c *gin.Context, data interface{}) {
	c.JSON(http.StatusOK, gin.H{"code": 200, "msg": "ok", "data": data})
}

func (response) Error(c *gin.Context, msg string, data interface{}) {
	c.JSON(http.StatusOK, gin.H{"code": 300, "msg": msg, "data": data})
}

func (response) NoAuth(c *gin.Context, data interface{}) {
	c.JSON(http.StatusOK, gin.H{"code": 400, "msg": "未授权", "data": data})
}
